package com.loyal.loyalerp.humenresource.employee.util;

import java.io.IOException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.loyal.loyalerp.basedata.department.mapper.DepartmentMapper;
import com.loyal.loyalerp.basedata.department.model.Department;

@Component
public class DeptidSerialize extends JsonSerializer<Integer> {
	
	@Autowired
	private DepartmentMapper deptMapper;

	@Override
	public void serialize(Integer deptid, JsonGenerator jg, SerializerProvider arg2)
			throws IOException, JsonProcessingException {
		
			Department dept=deptMapper.selectByPrimaryKey(deptid);
			jg.writeString(dept.getDeptName());
	}

}
